package com.yxw.springcloud.controller;

import com.yxw.springcloud.model.CommonResult;
import com.yxw.springcloud.model.Payment;
import com.yxw.springcloud.service.PaymentFeignService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

@RestController
public class OrderNacosController {


//    @Value("${service-url.nacos-user-service}")
//    private String serverURL;

    @Resource
    private RestTemplate restTemplate;

    @Resource
    private PaymentFeignService paymentFeignService;

    @GetMapping("/consumer/payment/nacos/{id}")
    public String paymentInfo(@PathVariable("id") Integer id){
        return paymentFeignService.getPayment(id);
//        return restTemplate.getForObject(serverURL+"/payment/nacos/"+id,String.class);
    }


    @GetMapping(value = "/consumer/payment/feign/timeout")
    public String paymentFeignTimeout(){
        //openfeign底层ribbon，客户端默认等待1秒钟
        return paymentFeignService.paymentFeignTimeout();
    }
}
